package com.dyz.leetcode._18_backtracking;

import java.util.ArrayList;
import java.util.List;

public class _78_subsets {
    public List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        if(nums==null|| nums.length==0){return res;}
        dfs(nums, 0, path, res);
        return res;

    }

    private void dfs(int[] nums,
                     int index,
                     List<Integer> path,
                     List<List<Integer>> res){
        res.add(new ArrayList<>(path));
        for (int i=index; i<nums.length; i++){
            path.add(nums[i]);
            dfs(nums, i+1, path, res);
            path.remove(path.size()-1);
        }
    }
}
